package com.cqjtu.tto.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.dev33.satoken.annotation.SaCheckRole;
import com.cqjtu.tto.dao.mapper.SysUserMapper;
import com.cqjtu.tto.service.RegisterService;
import com.cqjtu.tto.service.SysUserService;
import com.cqjtu.tto.vo.Results;
import com.cqjtu.tto.vo.params.RegisterParam;
import com.cqjtu.tto.vo.params.SysUserParam;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;

/**
 * @author：monkey-L
 * @description:
 * @date: 19:34 2021/12/11
 */
@RestController
@Api(tags = "用户模块")
public class SysUserController {

    @Autowired
    private SysUserService sysUserService;

    @Autowired
    private RegisterService registerService;

//    @SaCheckRole("admin")
//    @SaCheckRole("admin")
    @PostMapping("sysUserAdd")
    @ApiOperation(value = "增加用户")
    public Results sysUserAdd(@RequestBody RegisterParam registerParam) {
        return registerService.register(registerParam);
    }

//    @SaCheckRole("admin")
    @PostMapping("sysUserDelete")
    @ApiOperation(value = "删除用户",notes = "根据名字查询用户")
    public Results sysUserDelete(String userName) {
        return sysUserService.sysUserDelete(userName);
    }

//    @SaCheckRole("admin")
    @PostMapping("sysUserUpdate")
    @ApiOperation(value = "更新用户")
    public Results sysUserUpdate(@RequestBody SysUserParam sysUserParam) {
        return sysUserService.sysUserUpdate(sysUserParam);
    }

//    @SaCheckLogin
    @PostMapping("sysUserSelectOne")
    @ApiOperation(value = "查询用户",notes = "根据名字查询用户")
    public Results sysUserSelectOne(String userName) {
        return sysUserService.sysUserSelectOne(userName);
    }

//    @SaCheckRole("admin")
    @PostMapping("sysUserSelectList")
    @ApiOperation(value = "查询所有用户")
    public Results sysUserSelectList() {
        return sysUserService.sysUserSelectList();
    }

//    @SaCheckRole("admin")
    @GetMapping("customerExport")
    @ApiOperation(value = "客户信息打印")
    public void customerExport(HttpServletResponse response) {
        sysUserService.customerExport(response);
    }

//    @SaCheckRole("admin")
    @GetMapping("sysUserExport")
    @ApiOperation(value = "员工信息打印")
    public void sysUserExport(HttpServletResponse response) {
        sysUserService.sysUserExport(response);
    }
}
